Behaviors overview

Behaviors allow the user's interaction with the page to change the page, or to cause certain tasks to be performed. A behavior is a combination of an event and an action. For example, when the user moves the mouse over an image (an event), the image might highlight (an action). An action consists of prewritten JavaScript code that performs specific tasks, such as opening a browser window, playing a sound, or stopping a Shockwave movie. Events are defined by browsers for each page element; for example, onMouseOver, onMouseOut, and onClick are events associated with links in most browsers, whereas onLoad is an event associated with images and the document body. Events are generated by browsers in response to user actions; for example, when a visitor to your page moves the pointer over a link, the browser generates an onMouseOver event, and calls the JavaScript function (if any) that you've associated with that event. The events that you can use to trigger a given action vary from browser to browser.

When attaching a behavior to a page element, you specify an action and the event that triggers it. Several actions can all be triggered by the same event, and you can specify the order in which the actions occur.

Dreamweaver includes several behavior actions; additional actions can be found on the Dreamweaver Web site as well as on third-party developer sites. (See Downloading and installing third-party behaviors.) You can also write your own behavior actions if you are proficient in JavaScript. For more information on writing behavior actions, see Extending Dreamweaver.